-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve yaml serialization quoting #4217
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Drive-by-comments. I saw a regexp, so I had to say something.)
'null', 'Null', 'NULL', | ||
].contains(s)) return true; | ||
// Numbers must be quoted | ||
if (RegExp(r'^[-+]?[0-9]*\.?[0-9]*(e[0-9]+)?$').hasMatch(s)) return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a potentially dangerous RegExp because of the \d*\.?\d*
sequence. It's probably not exponential, but it can be quadratic in the length to reject something like 00000000000000000000000....0000000x
Consider changing to \d*(\.\d*)?
(And be aware that it still matches .
alone.)
// Numbers must be quoted | ||
if (RegExp(r'^[-+]?[0-9]*\.?[0-9]*(e[0-9]+)?$').hasMatch(s)) return true; | ||
// Hex numbers must be quoted | ||
if (RegExp(r'^0x[0-9]+$').hasMatch(s)) return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be [0-9a-fA-F]
.
/// which means some strings may be unnecessarily quoted. | ||
bool _needsYamlQuotes(String s) { | ||
// These must be quoted | ||
if ([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List can be const
. (Small save, but save, over creating a new list on every invocation.)
#4214
We should only merge this if we want accept disturbing almost all pubspec.locks.
Maybe we can bundle it with another update to pubspec.lock structure.
We can also make a smalller update that just fixes bugs.